/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vista;

import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import util.components.IGestorABM;
import util.validation.CreadorCriterios;

/**
 *
 * @author raul
 */
public abstract class GestorVistaABMPnl extends GestorVista 
    implements IGestorPanel, IGestorABM {
    
    protected ImageIcon createImageIcon(String path) {
        java.net.URL imgURL = GestorVistaABMPnl.class.getResource(path);
        if (imgURL != null) {
            return new ImageIcon(imgURL);
        } else {
            System.err.println("Couldn't find file: " + path);
            return null;
        }
    }

    public void buscar() {
        CreadorCriterios c = new CreadorCriterios();
        c.crearCriterios(getFormulario());
        if (!c.isFormularioVacio()) {
            cargarModeloComponente();
            List result = getGestorModelo().buscar(c.getCriterios());
            if (!result.isEmpty()) {
                cargarDatos(result);
            } else {
                JOptionPane.showMessageDialog(getFormulario(), "No hay resultados");
            }
        }
    }
}
